import 'package:flutter/material.dart';
import 'package:flutterlib/common/net/dao_result.dart';
import 'package:flutterlib/common/style/quhui_style.dart';
import 'package:flutterlib/common/utils/utils.dart';
import 'package:flutterlib/model/activity/activity.dart';
import 'package:flutterlib/widgets/bussiness/activity/activity_list_item_new.dart';
import 'package:flutterlib/widgets/pull/nested/simple_pull_load_manger.dart';
import 'package:flutterlib/widgets/pull/nested/simple_pull_load_page_widget.dart';

class ActivityMineListWidgetPage extends StatefulWidget {
  final int type;
  final List<Activity> activitys;

  ActivityMineListWidgetPage({Key key, this.type, this.activitys})
      : super(key: key);

  @override
  ActivityMineListWidgetPageState createState() =>
      ActivityMineListWidgetPageState();
}

///页面 KeepAlive ，同时支持 动画Ticker
class ActivityMineListWidgetPageState extends State<ActivityMineListWidgetPage>
    with TickerProviderStateMixin {
  SimplePullLoadManger manger;

  ///滑动监听
  final ScrollController scrollController = new ScrollController();

  getDataLogic(int page) async {
    print(page);

    return new DataResult(widget.activitys, true);
  }

  Widget renderItem(index, activity) {
    //提交
    // var activity = pullLoadWidgetControl.dataList[index];
    return ActivityListItemNew(activity, onPressed: () {
      NavigatorUtils.gotoActivityDetail(context, activity.id);
    });
  }

  @override
  void initState() {
    super.initState();
    manger = SimplePullLoadManger(
      getDataLogic: getDataLogic,
      renderItem: renderItem,
      enablePullUp: false,
      enablePullDown: false,
    );
  }

  @override
  Widget build(BuildContext context) {
    return new Container(
      color: QuhuiColors.mainBackgroundColor,
      child: SimplePullLoadWidget(
        pullLoadManger: manger,
      ),
    );
  }
}
